using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.Serialization;
using Granite.Modeling;

namespace Rifts.Models.Characters
{
	[DataContract]
	public class FightingStyleCollection : ChangeTrackingModelCollection<FightingStyle>
	{
		protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
		{
			base.OnCollectionChanged(e);
			OnPropertyChanged("Primary");
			OnPropertyChanged("Secondary");
		}

		public FightingStyle Primary
		{
			get { return Count >= 1 ? this[0] : null; }
		}

		public FightingStyle Secondary
		{
			get { return Count >= 2 ? this[1] : null; }
		}

		public FightingStyle FindByName(string name)
		{
			return this.FirstOrDefault(s => s.Name == name);
		}
	}
}
